
<div class="span12">
    <div class="box box-color box-bordered">
        <div class="box-title">
            <h3>
                <i class="icon-table"></i>
                Checklist
            </h3>
            <div class="actions">
                <?php if (myCapability::testcap($caps, myCapability::C('CAP_M_ADMIN_ORDER'))) { ?>
                    <a href="#mdlOrder" role="button" class="btn" data-toggle="modal"><i class="icon-table"></i></a>
                <?php } ?>
                <?php if (myCapability::testcap($caps, myCapability::C('CAP_M_ADMIN_FILTER'))) { ?>
                    <!--a href="#mdlFilter" role="button" class="btn" data-toggle="modal"><i class="icon-search"></i></a-->
                <?php } ?>
                <?php if (myCapability::testcap($caps, myCapability::C('CAP_M_ADMIN_EXCEL'))) { ?>
                    <a href="<?php echo url_for('/checklist/excelChecklist');?>?id=<?php echo $_GET['id'];?>" role="button" class="btn" ><i class="icon-download-alt"></i></a>
                <?php } ?>
              
            </div>
        </div>
        <div class="box-content nopadding">
            
            <?php //echo $userOrderCount;die();
            
            if($userOrderCount !=0){
            ?>
            <table class="table table-bordered dataTable dataTable-scroll-x">
                <thead>
                    <tr>
                        <?php 
                        foreach ($userTableOrder as $value) {?>
                            
                       
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==73 && $value['UserTableOrder'][0]['visible']==1){?><th>Check</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==74 && $value['UserTableOrder'][0]['visible']==1){?><th>Categoría</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==75 && $value['UserTableOrder'][0]['visible']==1){?><th>Objetivo</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==76 && $value['UserTableOrder'][0]['visible']==1){?><th>Medición</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==77 && $value['UserTableOrder'][0]['visible']==1){?><th>Promedio Semanal</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==78 && $value['UserTableOrder'][0]['visible']==1){?><th>Promedio Mensual</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==79 && $value['UserTableOrder'][0]['visible']==1){?><th>Cumplimiento</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==80 && $value['UserTableOrder'][0]['visible']==1){?><th>Cobertura Semanal</th><?php }?>
                        <?php if($value['UserTableOrder'][0]['id_tablecolumn']==81 && $value['UserTableOrder'][0]['visible']==1){?><th>Cobertura Mensual</th><?php }?>
                        
                        
                        <?php }?>
                    </tr>
                </thead>
                <tbody>
                    
                        <?php
                        $dataArray = array();
                        $i = 0;
                        foreach ($checklists as $value) {

                            $dataArray[$i][]['check'] = $value['name'];
                            $dataArray[$i][]['categoria'] = $value['CategoryProduct']['name'];
                            $dataArray[$i][]['objetivo'] = $value['target'];
                            $dataArray[$i][]['medicion'] = $value['observed_check'];
                            $dataArray[$i][]['pSemanal'] = $value['average_week'];
                            $dataArray[$i][]['pMensual'] = $value['average_month'];
                            $dataArray[$i][]['cumplimiento'] = $value['completed'];
                            $dataArray[$i][]['cSemanal'] = $value['coverage_weekly'];
                            $dataArray[$i][]['cMensual'] = $value['coverage_monthly'];
                            $i++;
                        }


                        for ($x = 0; $x < $i; $x++) {
                            ?>
                            <tr>

                                        <?php foreach ($userTableOrder as $value) { ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 73 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][0]['check']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 74 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][1]['categoria']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 75 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][2]['objetivo']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 76 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][3]['medicion']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 77 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][4]['pSemanal']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 78 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][5]['pMensual']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 79 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][6]['cumplimiento']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 80 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][7]['cSemanal']; ?></td><?php } ?>
                                            <?php if ($value['UserTableOrder'][0]['id_tablecolumn'] == 81 && $value['UserTableOrder'][0]['visible']==1) { ?><td><?php echo $dataArray[$x][8]['cMensual']; ?></td><?php } ?>
                                        <?php }
                                        ?>
                            </tr>
                            <?php
                        }
                        ?>

                </tbody>
            </table>
            
            <?php }else{ ?>  
            
            <table class="table table-bordered dataTable dataTable-scroll-x">
                <thead>
                    <tr>
                        <th>Check</th>
                        <th>Categoría</th>
                        <th>Objetivo</th>
                        <th>Medición</th>
                        <th>Promedio Semanal</th>
                        <th>Promedio Mensual</th>
                        <th>Cumplimiento</th>
                        <th>Cobertura Semanal</th>
                        <th>Cobertura Mensual</th>
                    </tr>
                </thead>
                <tbody>
                        
                    <?php foreach ($checklists as $value) { ?>

                        <tr>
                            <td><?php echo $value['name'];?></td>
                            <td><?php echo $value['CategoryProduct']['name'];?></td>
                            <td><?php echo $value['target'];?></td>
                            <td><?php echo $value['observed_check'];?></td>
                            <td><?php echo $value['average_week'];?></td>
                            <td><?php echo $value['average_month'];?></td>
                            <td><?php echo $value['completed'];?></td>
                            <td><?php echo $value['coverage_weekly'];?></td>
                            <td><?php echo $value['coverage_monthly'];?></td>
                        </tr>
                    <?php } ?>

                </tbody>
            </table>
            
            
            <?php }?>
        </div>
    </div>
</div>